helloprojectfandomcom_ja-20200214-history
モジュール:Sandbox/BirthdayTest
local p = {} D = {} J = {} T = {} function BirthdayInsert(Date, Japanese, Transliterated) --table.insert(D, Date) D#D+1 = Date; --table.insert(J, Japanese) J#J+1 = Japanese --table.insert(T, Transliterated) T#T+1 = Transliterated end --When adding, do so in the right place. It's first ordered by day, then within days by years oldest to newest. --This way it's already in an order best for most of the birthday functions, and no sorting needs to be programmed in. BirthdayInsert('1995-01-07', '佐藤綾乃', 'Sato Ayano') BirthdayInsert('1997-01-07', '石田亜佑美', 'Ishida Ayumi') BirthdayInsert('1988-01-10', '吳思璇', 'Wu Si Xuan') BirthdayInsert('1993-01-12', '光井愛佳', 'Mitsui Aika') BirthdayInsert('1999-01-14', '茂木美奈実', 'Mogi Minami') BirthdayInsert('1994-01-16', '邱翠玲', 'Qiu Cui Ling') BirthdayInsert('1985-01-19', '石川梨華', 'Ishikawa Rika') BirthdayInsert('1983-01-20', '矢口真里', 'Yaguchi Mari') BirthdayInsert('1984-01-27', '平野智美', 'Hirano Tomomi') BirthdayInsert('1977-01-30', '小林梓', 'Kobayashi Azusa') BirthdayInsert('1992-01-31', '武藤水華', 'Muto Mika') BirthdayInsert('2001-02-02', '牧野真莉愛', 'Makino Maria') BirthdayInsert('1994-02-05', '中島早貴', 'Nakajima Saki') BirthdayInsert('1981-02-06', '戸田鈴音', 'Toda Rinne') BirthdayInsert('1983-02-07', 'レフア・サンボ', 'Lehua Sandbo') BirthdayInsert('1988-02-07', '加護亜依', 'Kago Ai') BirthdayInsert('1992-02-07', '矢島舞美', 'Yajima Maimi') BirthdayInsert('1996-02-07', '萩原舞', 'Hagiwara Mai') BirthdayInsert('1985-02-09', '深谷愛', 'Fukaya Ai') BirthdayInsert('1991-02-10', '曾德萍', 'Ceng De Ping') BirthdayInsert('2000-02-10', '野村みな美', 'Nomura Minami') BirthdayInsert('1987-02-12', '斉藤美海', 'Saito Miuna') BirthdayInsert('1977-02-15', '小湊美和', 'Kominato Miwa') BirthdayInsert('1989-02-15', '永井沙紀', 'Nagai Saki') BirthdayInsert('1984-02-22', '柴田あゆみ', 'Shibata Ayumi') BirthdayInsert('1982-02-25', '大谷雅恵', 'Otani Masae') BirthdayInsert('1999-02-25', '一岡怜奈', 'Ichioka Reina') BirthdayInsert('1980-02-26', '石井里佳', 'Ishii Rika') BirthdayInsert('1985-02-26', '藤本美貴', 'Fujimoto Miki') BirthdayInsert('1982-03-02', '大木衣吹', 'Oki Ibuki') BirthdayInsert('1981-03-03', '村田めぐみ', 'Murata Megumi') BirthdayInsert('1999-03-04', '藤井梨央', 'Fujii Rio') BirthdayInsert('1990-03-06', '菅原佳奈枝', 'Sugawara Kanae') BirthdayInsert('1992-03-06', '嗣永桃子', 'Tsugunaga Momoko') BirthdayInsert('2002-03-07', '羽賀朱音', 'Haga Akane') BirthdayInsert('1978-03-08', '荒井紗紀', 'Arai Saki') BirthdayInsert('2001-03-08', '和田桜子', 'Wada Sakurako') BirthdayInsert('1991-03-11', 'リンリン', 'Linlin') BirthdayInsert('1995-03-12', '福田花音', 'Fukuda Kanon') BirthdayInsert('1999-03-12', '小田さくら', 'Oda Sakura') BirthdayInsert('1974-03-13', '稲葉貴子', 'Inaba Atsuko') BirthdayInsert('1999-03-14', '横川夢衣', 'Yokogawa Yumei') BirthdayInsert('1993-03-15', '岡田ロビン翔子', 'Okada Robin Shoko') BirthdayInsert('1976-03-18', '本多ルル', 'Honda Ruru') BirthdayInsert('1999-03-26', '相川茉穂', 'Aikawa Maho') BirthdayInsert('2000-03-27', '小川麗奈', 'Ogawa Rena') BirthdayInsert('1984-03-29', '里田まい', 'Satoda Mai') BirthdayInsert('2000-04-01', '岸本ゆめの', 'Kishimoto Yumeno') BirthdayInsert('1994-04-02', '宮崎由加', 'Miyazaki Yuka') BirthdayInsert('1992-04-03', '中山菜々', 'Nakayama Nana') BirthdayInsert('1998-04-03', '大塚愛菜', 'Otsuka Aina') BirthdayInsert('1994-04-04', '菅谷梨沙子', 'Sugaya Risako') BirthdayInsert('1979-04-06', '平家 みちよ', 'Heike Michiyo') BirthdayInsert('1998-04-06', '勝田里奈', 'Katsuta Rina') BirthdayInsert('1991-04-11', '真野恵里菜', 'Mano Erina') BirthdayInsert('1985-04-12', '吉澤ひとみ', 'Yoshizawa Hitomi') BirthdayInsert('1994-04-12', '鈴木愛理', 'Suzuki Airi') BirthdayInsert('1983-04-15', 'エイプリル・ババラン', 'April Barbaran') BirthdayInsert('1992-04-15', '須磨愛', 'Suma Ai') BirthdayInsert('1990-04-16', '青木英里奈', 'Aoki Erina') BirthdayInsert('1997-04-21', '高木紗友希', 'Takagi Sayuki') BirthdayInsert('1993-04-23', '尾野里紗', 'Ono Risa') BirthdayInsert('1991-04-25', '田中杏里', 'Tanaka Anri') BirthdayInsert('2000-04-26', '浜浦彩乃', 'Hamaura Ayano') BirthdayInsert('1983-04-28', '심순민', 'Shim Soon Min') BirthdayInsert('2001-04-28', '竹村未羽', 'Takemura Miu') BirthdayInsert('1991-04-29', '大瀬楓', 'Ohse Kaede') BirthdayInsert('1991-04-30', '仙石みなみ', 'Sengoku Minami') BirthdayInsert('1992-05-01', '吉川友', 'Kikkawa Yuu') BirthdayInsert('1987-05-07', '紺野あさ美', 'Konno Asami') BirthdayInsert('1997-05-07', '前田彩里', 'Maeda Irori') BirthdayInsert('1999-05-07', '佐藤優樹', 'Sato Masaki') BirthdayInsert('2001-05-07', '段原瑠々', 'Danbara Ruru') BirthdayInsert('2002-05-10', '船木結', 'Funaki Musubu') BirthdayInsert('1978-05-12', '石黒彩', 'Ishiguro Aya') BirthdayInsert('1996-05-14', '岡井明日菜', 'Okai Asuna') BirthdayInsert('1995-05-15', '山賀香菜恵', 'Yamaga Kanae') BirthdayInsert('1972-05-18', '信田美帆', 'Shinoda Mio') BirthdayInsert('1992-05-22', '徳永千奈美', 'Tokunaga Chinami') BirthdayInsert('1991-05-24', '梅田えりか', 'Umeda Erika') BirthdayInsert('1984-05-28', 'ミカ・タレッサ・トッド', 'Mika Todd') BirthdayInsert('1998-05-28', '鞘師里保', 'Sayashi Riho') BirthdayInsert('2001-05-28', '佐々木莉佳子', 'Sasaki Rikako') BirthdayInsert('1994-05-29', '瀬崎あずさ', 'Sezaki Azusa') BirthdayInsert('1997-06-04', '中西香菜', 'Nakanishi Kana') BirthdayInsert('1992-06-05', '古川小夏', 'Furukawa Konatsu') BirthdayInsert('1992-06-06', '村上愛', 'Murakami Megumi') BirthdayInsert('1995-06-08', '佐保明梨', 'Saho Akari') BirthdayInsert('1993-06-12', '後藤夕貴', 'Goto Yuki') BirthdayInsert('1998-06-12', '室田瑞希', 'Murota Mizuki') BirthdayInsert('1996-06-14', '関根梓', 'Sekine Azusa') BirthdayInsert('1993-06-15', '有原栞菜', 'Arihara Kanna') BirthdayInsert('1987-06-17', '辻希美', 'Tsuji Nozomi') BirthdayInsert('1973-06-19', '中澤裕子', 'Nakazawa Yuko') BirthdayInsert('1994-06-21', '岡井千聖', 'Okai Chisato') BirthdayInsert('1993-06-22', '西念未彩', 'Sainen Mia') BirthdayInsert('1986-06-25', '松浦亜弥', 'Matsuura Aya') BirthdayInsert('1994-06-27', '古峰桃香', 'Komine Momoka') BirthdayInsert('1997-07-01', '金子りえ', 'Kaneko Rie') BirthdayInsert('1995-07-02', '金澤朋子', 'Kanazawa Tomoko') BirthdayInsert('1992-07-03', '須藤茉麻', 'Sudo Maasa') BirthdayInsert('1990-07-04', '矢口めぐみ', 'Yaguchi Megumi') BirthdayInsert('1965-07-05', '小西貴雄', 'Konishi Takao') BirthdayInsert('1997-07-07', '生田衣梨奈', 'Ikuta Erina') BirthdayInsert('1985-07-11', '藤咲裕美', 'Fujisaki Hiromi') BirthdayInsert('1989-07-13', '道重さゆみ', 'Michishige Sayumi') BirthdayInsert('1991-07-13', '小倉愛実', 'Ogura Manami') BirthdayInsert('1992-07-15', '久住小春', 'Kusumi Koharu') BirthdayInsert('1984-07-17', '木村麻美', 'Kimura Asami') BirthdayInsert('2000-07-21', '田口夏実', 'Taguchi Natsumi') BirthdayInsert('1980-07-22', '北上アミ', 'Kitagami Ami') BirthdayInsert('1998-07-28', '岡村里星', 'Okamura Rise') BirthdayInsert('1989-07-23', '鍾安琪', 'Zhong An Qi') BirthdayInsert('1994-08-01', '和田彩花', 'Wada Ayaka') BirthdayInsert('1998-08-05', '鈴木香音', 'Suzuki Kanon') BirthdayInsert('1981-08-08', '飯田圭織', 'Iida Kaori') BirthdayInsert('1981-08-10', '安倍なつみ', 'Abe Natsumi') BirthdayInsert('1979-08-14', '三佳千夏', 'Miyoshi Chinatsu') BirthdayInsert('1992-08-25', '夏焼雅', 'Natsuyaki Miyabi') BirthdayInsert('1986-08-26', '川島幸', 'Kawashima Miyuki') BirthdayInsert('2001-08-26', '斎藤夏奈', 'Saito Kana') BirthdayInsert('1979-08-28', '前田有紀', 'Maeda Yuki') BirthdayInsert('1992-08-28', '趙國蓉', 'Zhao Guo Rong') BirthdayInsert('1998-08-28', '三瓶海南', 'Mikame Kana') BirthdayInsert('1999-08-29', '真城佳奈', 'Mashiro Kana') BirthdayInsert('2000-08-31', '井上ひかる', 'Inoue Hikaru') BirthdayInsert('1990-09-05', '阿部麻美', 'Abe Asami') BirthdayInsert('1983-09-06', 'ダニエル・デラウニー', 'Danielle Delaunay') BirthdayInsert('1996-09-06', '木沢留那', 'Kizawa Runa') BirthdayInsert('2000-09-10', '大浦央菜', 'Oura Hirona') BirthdayInsert('1986-09-14', '高橋愛', 'Takahashi Ai') BirthdayInsert('1995-09-19', '장다연', 'Jang Da Yeon') BirthdayInsert('1999-09-22', '吉橋くるみ', 'Yoshihashi Kurumi') BirthdayInsert('1985-09-23', '後藤真希', 'Goto Maki') BirthdayInsert('1982-09-26', 'チェルシー・チン', 'Chelsea Ching') BirthdayInsert('1992-10-03', '橋本愛奈', 'Hashimoto Aina') BirthdayInsert('1992-10-12', '大柳まほ', 'Ooyanagi Maho') BirthdayInsert('1993-10-12', '森咲樹', 'Mori Saki') BirthdayInsert('1997-10-14', '山木梨沙', 'Yamaki Risa') BirthdayInsert('1979-10-19', '柳原尋美', 'Yanagihara Hiromi') BirthdayInsert('1992-10-19', '秋山ゆりか', 'Akiyama Yurika') BirthdayInsert('1993-10-19', '湯徳歩美', 'Yutoku Ayumi') BirthdayInsert('1988-10-20', '新垣里沙', 'Niigaki Risa') BirthdayInsert('1999-10-20', '新沼希空', 'Niinuma Kisora') BirthdayInsert('1980-10-23', '末永真己', 'Suenaga Mami') BirthdayInsert('1999-10-27', '工藤遥', 'Kudo Haruka') BirthdayInsert('1968-10-29', 'つんく', 'Tsunku') BirthdayInsert('1987-10-29', '小川麻琴', 'Ogawa Makoto') BirthdayInsert('1981-10-30', '木村絢香', 'Kimura Ayaka') BirthdayInsert('1996-10-30', '譜久村聖', 'Fukumura Mizuki') BirthdayInsert('1998-10-30', '田村芽実', 'Tamura Meimi') BirthdayInsert('1981-10-31', '斉藤瞳', 'Saito Hitomi') BirthdayInsert('1989-11-01', '諸塚香奈実', 'Morozuka Kanami') BirthdayInsert('1985-11-04', '是永美記', 'Korenaga Miki') BirthdayInsert('1994-11-07', '飯窪春菜', 'Iikubo Haruna') BirthdayInsert('1984-11-08', '三好絵梨香', 'Miyoshi Erika') BirthdayInsert('1996-11-08', '長澤和奏', 'Nagasawa Wakana') BirthdayInsert('1999-11-10', '田辺奈菜美', 'Tanabe Nanami') BirthdayInsert('1989-11-11', '田中れいな', 'Tanaka Reina') BirthdayInsert('1996-11-18', '小川紗季', 'Ogawa Saki') BirthdayInsert('1997-11-19', '新井愛瞳', 'Aarai Manami') BirthdayInsert('1997-11-19', '小数賀芙由香', 'Kosuga Fuyuka') BirthdayInsert('1992-11-20', '石村舞波', 'Ishimura Maiha') BirthdayInsert('1991-11-22', '清水佐紀', 'Shimizu Saki') BirthdayInsert('1997-11-23', '竹内朱莉', 'Takeuchi Akari') BirthdayInsert('1998-11-24', '山岸理子', 'Yamagishi Riko') BirthdayInsert('1991-11-25', '澤田由梨', 'Sawada Yuri') BirthdayInsert('1993-11-29', '北原沙弥香', 'Kitahara Sayaka') BirthdayInsert('1999-11-30', '加賀楓', 'Kaga Kaede') BirthdayInsert('1998-12-01', '宮本佳林', 'Miyamoto Karin') BirthdayInsert('1985-12-04', '曽根菜津子', 'Sone Natsuko') BirthdayInsert('1980-12-06', '保田圭', 'Yasuda Kei') BirthdayInsert('1996-12-14', '古筠', 'Gu Yun') BirthdayInsert('1984-12-17', '福田明日香', 'Fukuda Asuka') BirthdayInsert('1989-12-17', '岩嶋雅奈未', 'Iwashima Manami') BirthdayInsert('2002-12-21', '藍愛子', 'Lan Ai Zi') BirthdayInsert('1988-12-23', '亀井絵里', 'Kamei Eri') BirthdayInsert('1997-12-24', '田中可恋', 'Tanaka Karen') BirthdayInsert('1988-12-26', '能登有沙', 'Noto Arisa') BirthdayInsert('1997-12-27', '稲場愛香', 'Inaba Manaka') BirthdayInsert('2000-12-27', '吳兆絃', 'Wu Zhao Xian') BirthdayInsert('1987-12-28', '岡田唯', 'Okada Yui') BirthdayInsert('1994-12-28', '前田憂佳', 'Maeda Yuuka') BirthdayInsert('1998-12-30', '植村あかり', 'Uemura Akari') BirthdayInsert('1983-12-31', '市井紗耶香', 'Ichii Sayaka') function p.JustClock() return " " .. os.clock() end function JDateFix(jdate) --Default date options leave unwanted 0s and spaces in places. Let's eliminate them. output = string.gsub (jdate, "0(%d月)", "%1") output = string.gsub (output, " (%d日)", "%1") return output end function YYYYMMDDtoJ(yyyymmdd) --This doesn't fix malformed mini-jdates, but changes proper YYYYMMMDD into proper full jdates output = string.gsub (yyyymmdd, "(%d%d%d%d)-(%d%d)-(%d%d)", "%1年%2月%3日") output = string.gsub (output, "0(%d月)", "%1") output = string.gsub (output, "0(%d日)", "%1") return output end function Ordinal(anumber) --Japanese doesn't seem to screw around with different types like st, nd, rd return "第" .. anumber .. "回" end function WhichBirthday(yyyymmdd) --Just rounds to which age is nearest. For standard uses of looking forward a week, it does the trick. _, _, y, m, d = string.find(yyyymmdd, "(%d%d%d%d)-(%d%d)-(%d%d)") difference = os.time() - os.time{year=y, month=m, day=d} difference = difference / 31555008 difference = math.floor(difference+0.5) --Rounding return Ordinal(difference) end function WhereDayXStarts(mmdd) i = 0 repeat i=i+1 until string.sub( Di, 6, 10 ) >= mmdd or i table.getn(D) if string.sub(Di, 6, 10) < mmdd then i = 1 end --If we've gone all the way and found squat, stick to the beginning. return i --.. " " .. string.sub( Di, 6, 10 ) .. " >= " .. mmdd .. " or i " .. table.getn(D) end function WhereDayXEnds(mmdd) _, _, m, d = string.find(mmdd, "(%d%d)-(%d%d)") if d+1 < 10 then nextday = m .. "-0" .. d+1 --Needs zero padded else nextday = m .. "-" .. d+1 --Even if this date isnt' real, it should work as a point of comparison end if nextday "12-32" then return table.getn(D) -- As long as things are properly ordered, the table ends with the end of the year. else thisdaybegins = WhereDayXStarts(mmdd) itbegins = WhereDayXStarts(nextday) if(thisdaybegins itbegins) then --Next day starts no later than today, so no need to subtract 1. ThenWhereDayXEnds = itbegins else ThenWhereDayXEnds = itbegins - 1 --Just before where the next day starts, see. if ThenWhereDayXEnds 0 then ThenWhereDayXEnds = table.getn(D) end --Again if the very beginning is "after", the end is... the end. end return ThenWhereDayXEnds end end function p.upcoming(frame) local num_days = tonumber(frame.args.days or 7) local num_min = tonumber(frame.args.min or 2) local starting = frame.args.starting or os.date("%m-%d",os.time()+32400) local ending = os.date("%m-%d", os.time{year=2001, month=string.sub(starting,1,2), day=string.sub(starting,4,5)}+86400*(num_days-1)) local STARTBEGINS = WhereDayXStarts(starting) local ENDENDS = WhereDayXEnds(ending) local LISTEND = table.getn(D) -- if STARTBEGINS ENDENDS then --Make it the next one or it loops the whole year. -- ENDENDS=STARTBEGINS+1 -- if ENDENDS > LISTEND then ENDENDS=1 end -- end local output = "starting: " .. starting .. " ending: " .. ending .. " STARTBEGINS: " .. STARTBEGINS .. " ENDENDS: " .. ENDENDS .. " LISTEND: " .. LISTEND local startread1 = 0 local endread1 = 0 local startread2 = 0 local endread2 = -1 if ENDENDS>=STARTBEGINS then if (ENDENDS-STARTBEGINS+1) >= num_min then --Is Y greater than X and Y-X>=Min? Fantastic! Read from spots X through Y. output = output .. " CASE 1 " startread1 = STARTBEGINS endread1 = ENDENDS startread2 = 0 elseif (LISTEND-STARTBEGINS+1) >= num_min then --Is Y greater than X, Y-X=Min? OK, find what date X+Min is, find where that date ends, call it Y. Read from spots X through Y. output = output .. " CASE 2 " ending = string.sub(DSTARTBEGINS+num_min-1, 6, 10 ) --mm-dd for minimum spot ENDENDS = WhereDayXEnds(ending) startread1 = STARTBEGINS endread1 = ENDENDS else --Need more to hit minimum, rest of list isn't enough. Need to check beginning of list for end of minimum and read those too. output = output .. " CASE 3 " ending = string.sub(Dnum_min-(LISTEND-STARTBEGINS+1), 6, 10 ) --mm-dd for minimum spot ENDENDS = WhereDayXEnds(ending) startread1 = STARTBEGINS endread1 = LISTEND startread2 = 1 endread2 = ENDENDS end else if (LISTEND-STARTBEGINS+ENDENDS) >= num_min then --Is Y less than X and (End-X+Y)>=Min? Read from spots X through End, then 1 through Y. output = output .. " CASE 4 " startread1 = STARTBEGINS endread1 = LISTEND startread2 = 1 endread2 = ENDENDS else --Is Y less than X, (End-X+Y)= HIGHBORDER and Di <= LOWBORDER then output = output .. ":[.. J[i .. "]] (" .. Di .. ")\n" end i=i+1 end --Second half i = 1 while i<= STARTBEGINS-1 do if Di >= HIGHBORDER and Di <= LOWBORDER then output = output .. ":[.. J[i .. "]] (" .. Di .. ")\n" end i=i+1 end output = YYYYMMDDtoJ(output) return output end function p.between(frame) startdate=frame.args1 enddate=frame.args2 if startdate > enddate then --You trying to screw things up? Well, we'll just flip 'em. temp = startdate startdate = enddate enddate = temp end output = "" year = string.sub(startdate,1,4) while year<=string.sub(enddate,1,4) do if year string.sub(startdate,1,4) then lowcomparison = string.sub(startdate,6,10) --If it's the first year, only start at the given date else lowcomparison = '01-01' end if year string.sub(enddate,1,4) then highcomparison = string.sub(enddate,6,10) --If it's the last year, stop by the given date else highcomparison = '12-31' end i = 1 while i<= table.getn(D) do if string.sub(Di,1,4) year and string.sub(Di,6,10) >= lowcomparison and string.sub(Di,6,10) <= highcomparison then output = output .. ":[.. J[i .. "]] (" .. Di .. ")\n" end i=i+1 end year=tostring(year+1) end output = YYYYMMDDtoJ(output) return output end function p.test(frame) start = frame.args1 or "08月 8日" --output = string.gsub (start, "0(%d月)", "%1") -- output = string.gsub (output, " (%d日)", "%1") output = JDateFix(start) return output end function p.test2(frame) start = frame.args1 or "1982-08-07" output = start .. " " result = string.gsub (start, "(%d%d%d%d)-(%d%d)-(%d%d)", "%1年%2月%3日") output = output .. result .. " " result = string.gsub (result, "0(%d月)", "%1") output = output .. result .. " " result = string.gsub (result, "0(%d日)", "%1") output = output .. result .. " " --output = YYYYMMDDtoJ(start) return output end function p.test3() local STARTBEGINS = WhereDayXStarts('08-15') local ENDENDS = WhereDayXEnds('08-21') output = WhereDayXStarts('08-15') .. " " .. WhereDayXEnds('08-15') .. " " .. WhereDayXStarts('08-21') .. " " .. WhereDayXEnds('08-21') return output end return p